﻿<Window x:Class="WpfExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib"
        xmlns:local="clr-namespace:WpfExample"
        Title="WPF Example" Height="350" Width="525">
    <Window.Resources>
        <Style TargetType="Label">
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="Width" Value="160"/>
        </Style>
        <local:QuantityConverter x:Key="QuantityConverter"/>
    </Window.Resources>
    <Grid>
        <UniformGrid Columns="2" HorizontalAlignment="Center" VerticalAlignment="Center">
            <Label Content="Length:"/>
            <TextBox Text="{Binding Length, Converter={StaticResource QuantityConverter}}"/>
            <Label Content="Time:"/>
            <TextBox Text="{Binding Time, Converter={StaticResource QuantityConverter}}"/>
            <Label Content="Velocity:"/>
            <TextBox Text="{Binding Velocity, Converter={StaticResource QuantityConverter}, Mode=OneWay, ConverterParameter='0.00'}"/>
            <Label Content=""/>
            <TextBox Text="{Binding Velocity, Converter={StaticResource QuantityConverter}, Mode=OneWay, ConverterParameter='0.00 km/h'}"/>
            <Label Content="Mass:" ToolTip="This is a nullable property, and the target will be set to null when the textbox is empty"/>
            <TextBox Text="{Binding Mass, Converter={StaticResource QuantityConverter}, TargetNullValue={x:Static sys:String.Empty}}"/>
        </UniformGrid>
    </Grid>
</Window>
